package qianfeng.com.meijiadaka.viewholder;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import java.util.List;
import cn.lemon.view.adapter.BaseViewHolder;
import qianfeng.com.meijiadaka.R;
import qianfeng.com.meijiadaka.adapter.MyListAdapter;
import qianfeng.com.meijiadaka.bean.Home_info1;
import qianfeng.com.meijiadaka.bean.TypeBean;

public class ListViewHolder extends BaseViewHolder<TypeBean>{
private CallBack mCallBack;

    public void setCallBack(CallBack callBack) {
        mCallBack = callBack;
    }

    public interface CallBack{
        void setOnClick();
    }
    private RecyclerView mRecyclerView;
    @Override
    public void onInitializeView() {
        super.onInitializeView();
        mRecyclerView=findViewById(R.id.home_adapter_rv);
    }

    @Override
    public void onItemViewClick(TypeBean object) {
        super.onItemViewClick(object);
    }

    @Override
    public void setData(TypeBean object) {
        super.setData(object);
        GridLayoutManager manager=new GridLayoutManager(itemView.getContext(),5);
        manager.setOrientation(LinearLayoutManager.VERTICAL);
        mRecyclerView.setLayoutManager(manager);
        MyListAdapter adapter = new MyListAdapter(itemView.getContext(), object.getCategoriesBeen());
        mRecyclerView.setAdapter(adapter);
        adapter.setCallBack(new MyListAdapter.CallBack() {
            @Override
            public void setOnClick() {
                mCallBack.setOnClick();
            }
        });
    }

    public ListViewHolder(ViewGroup parent) {
        super(parent, R.layout.home_adapter);
    }
}

